package com.detroitchow;

import java.io.Serializable;
import java.util.ArrayList;


public class StoreVO implements Comparable<StoreVO>, Serializable{
  
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	public final String NEW_LINE="\n";
	public final String EMPTY_SPACE=" ";
  public int storeId;
  public String name;
  public String descr;
  public String address;
  public String city;
  public String state;
  public String zip;
  public String lat;
  public String lng;
  public String phone;
  public String facebook;
  public String twitter;
  public String email;
  public String googlePlus;
  public String website;
  public String shortReview;
  public int rank=0;
  public ArrayList<String> tags;
  public int isListItem;
  public int mapGroupId;
  public String mapDescr;
  
  public String getMapTitle() {
  	if(this.name == null)
  		return "";
  	else
  		return this.name;
  }
  
  public String getSnippetLayout() {
  	String result="";
  	
  	if(isLegitValue(this.mapDescr))
  		result = this.mapDescr + NEW_LINE + EMPTY_SPACE + NEW_LINE;
  	
  	if(isLegitValue(this.address))
  		result += this.address;
  	
  	if(isLegitValue(this.city)  && isLegitValue(this.state) && isLegitValue(this.zip))
  		result += NEW_LINE + this.city + EMPTY_SPACE + this.state + EMPTY_SPACE + this.zip;
  	else if(this.city != null)
  		result += NEW_LINE + this.city;
  	
  	if(isLegitValue(this.phone)) {
  		result += NEW_LINE + DetroitChowUtils.formattedPhoneNumber(this.phone);
  	}
  	
  	if(isLegitValue(this.website)) {
  		result += NEW_LINE + this.website;
  	}
  	
  	return result;
  }
  
  public boolean isLegitValue(String s){
  	if(s == null)
  		return false;
    if(s.length() < 1)
    	return false;
  	return true;
  }
  
  public String toString() {
  	String result = "<StoreVO>\n<storeId>" + this.storeId + "</storeId>" + NEW_LINE;
  	result += "<name>" + this.name + "</name>" + NEW_LINE;
  	result += "<descr>" + this.descr + "</descr>" + NEW_LINE;
  	result += "<lat>" + this.lat + "</lat>" + NEW_LINE;
  	result += "<lng>" + this.lng + "</lng>" + NEW_LINE;
  	result += "<address>" + this.address + "</address>" + NEW_LINE;
  	result += "<city>" + this.city + "</city>" + NEW_LINE;
  	result += "<zip>" + this.zip + "</zip>" + NEW_LINE;
  	result += "<webSite>" + this.website + "</webSite>" + NEW_LINE;
  	result += "</StoreVO>";
  	
  	return result;
  }
  
  public int compareTo(StoreVO another) {
	  // TODO Auto-generated method stub
		return this.name.compareTo(another.name);
  }
  

}
